#ifndef N1UNICODESTRING_H_2009_10_04
#define N1UNICODESTRING_H_2009_10_04

#include "N1Lib.h"

class N1Object;

class N1UnicodeString : public N1Object {
public:
    typedef wchar_t   N1StringChar;

protected:
    //pointer to string
    N1StringChar  *m_pStr;

    //if 0 - m_pStr points to not our data
    //else it is size of buffer
    N1UInt32       m_nRealCount; 

    N1StringChar* alloc(N1UInt32 count) const ;

public:
	N1UnicodeString();

	N1UnicodeString(const N1StringChar* str);

	N1UnicodeString(const N1UnicodeString &str);

	virtual ~N1UnicodeString();

    N1NAME_DECL

	N1UInt32 length() const ;

	void setLength(N1UInt32 len);

	operator N1StringChar*() { return m_pStr; };

	const N1StringChar* str() const { return m_pStr; };

	N1StringChar* str()	{ return m_pStr; };

	N1StringChar at(N1UInt32 index) const ;

	N1StringChar& operator [](int index) { return m_pStr[index]; };

	void format(const N1StringChar* format, ...);

	void formatv(const N1StringChar* format, va_list args);

	bool operator==(const N1UnicodeString& str) const ;

	bool operator==(const N1StringChar* str) const ;

	const N1UnicodeString& operator+=(N1StringChar *str);

	N1String* UTF8();

	void releaseBuffer();
};

#endif //N1UNICODESTRING_H_2009_10_04
